# Maintainer: Alexander F. Rødseth <xyproto@archlinux.org>
# Contributor: loqs <bugs-archlinux@entropy-collector.net>

pkgname=docopt
pkgver=0.6.3
pkgrel=4
pkgdesc='Command line arguments parser for C++11 and later'
arch=(loong64 x86_64)
url='https://github.com/docopt/docopt.cpp/'
license=('MIT')
makedepends=(cmake git ninja setconf)
source=("git+$url#commit=42ebcec9dc2c99a1b3a4542787572045763ad196" # tag: v0.6.3
        docopt.pc)
b2sums=('SKIP'
        'e56ac399d7fb587f1055eeaf8bdbe579714f108019ef7dfb6e9e26ec14fc7541ad1ff6996e2f89e13fa149e3192c13049c96f16e2e4e62fa16cb1389891e6c1d')

prepare() {
  setconf docopt.pc Version "$pkgver"
  cd docopt.cpp
  git cherry-pick -n 6d3b803d2b0e4bf8703bbfa51a67f378d6bd59f6 # only build one target, use BUILD_SHARED_LIBS where appropriate
}

build() {
  cmake -B build \
    -D CMAKE_BUILD_TYPE=Release \
    -D CMAKE_INSTALL_PREFIX=/usr \
    -D CMAKE_INSTALL_LIBDIR=lib \
    -D BUILD_SHARED_LIBS=ON \
    -G Ninja \
    -S docopt.cpp/
  ninja -C build
}

package() {
  DESTDIR="$pkgdir" ninja -C build install
  install -Dm644 docopt.cpp/LICENSE-MIT "$pkgdir/usr/share/licenses/docopt/LICENSE"
  install -Dm644 docopt.pc "$pkgdir/usr/lib/pkgconfig/docopt.pc"
}
